local thbattle__xiaowan_wanbaochui = fk.CreateSkill {

  name = "thbattle__xiaowan_wanbaochui",

  tags = {},

}



thbattle__xiaowan_wanbaochui:addEffect(fk.AskForRetrial, {
  prompt = "#thbattle__xiaowan_wanbaochui",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(thbattle__xiaowan_wanbaochui.name) and not player:isNude() and data.card.number < 13
  end,
    on_cost = function(self, event, target, player, data)
    local room = player.room
    local ids = table.filter(table.connect(player:getHandlyIds(), player:getCardIds("e")), function(id)
      return not player:prohibitResponse(Fk:getCardById(id)) and data.card.number<Fk:getCardById(id).number
    end)
    local cards = room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      skill_name = thbattle__xiaowan_wanbaochui.name,
      include_equip = true,
      pattern = tostring(Exppattern { id = ids }),
      prompt = "#thbattle__xiaowan_wanbaochui-ask::" .. target.id .. ":" .. data.reason,
      cancelable = true,
    })
    if #cards > 0 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:changeJudge {
      card = Fk:getCardById(event:getCostData(self).cards[1]),
      player = player,
      data = data,
      skill_name = thbattle__xiaowan_wanbaochui.name,
      response = true,
      exchange = true,
    }
  end,
})

return thbattle__xiaowan_wanbaochui
